package app.cn.com.school.adapter

import android.content.ContentValues
import android.content.Context
import android.databinding.DataBindingUtil
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import app.cn.com.school.R
import app.cn.com.school.databinding.StationeryItemBinding

/**
 * Created by Administrator on 2017/11/3 0003.
 */
class StationeryAdapter(private val context: Context, private val contentValues: List<ContentValues>) : BaseAdapter() {
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var binding: StationeryItemBinding? = null
        var convertView = convertView
        if (convertView == null) {
            binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.stationery_item, parent, false)
            convertView = binding.root
            convertView!!.tag = binding
        } else {
            binding = convertView!!.tag as StationeryItemBinding
        }
        if (contentValues!!.size <= position || contentValues == null) {
            return convertView
        }
        binding!!.staItemCity.text = "ssssssssssssssss"
        return convertView

    }

    override fun getItem(position: Int): Any {
        return position
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return contentValues?.size ?: 0
    }

}